<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/sys/include/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>添加园区信息</title>
<%@ include file="/WEB-INF/sys/include/css.jsp"%>
<link href="${path}/res/js/webuploader/webuploader.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form" action="${path}/park/save.json" method="post">
<div class="form">
	<div class="title">添加园区信息</div>
	<div class="group">
		<div class="label">*所属企业:</div>
		<div class="item">
			<input type="text" id="companyDisplay" name="companyDisplay" />
			<input type="hidden" name="companyid" id="companyid" />
		</div>
		<div class="item" id="companyDisplayTip"></div>
	</div>
	<div class="group">
		<div class="label">*园区名称:</div>
		<div class="item"><input type="text" name="parkName" id="parkName" maxlength="50" /></div>
	</div>
	<!--  <div class="group">
		<div class="label">*园区编号:</div>
		<div class="item"><input type="text" name="parkNo" id="parkNo" maxlength="20" /></div>
	</div> -->
	<c:if test="${empty groupid }">
	<div class="group">
		<div class="label">*所属分组:</div>
		<div class="item">
			<input type="text" id="groupDisplay" name="groupDisplay" />
			<input type="hidden" name="groupname" id="groupname" />
			<input type="hidden" name="groupid" id="groupid" />
		</div>
		<div class="item" id="groupDisplayTip"></div>
	</div>
	</c:if>
	<div class="group">
		<div class="label">园区地址:</div>
		<div class="item"><input type="text" name="parkAddress" id="parkAddress" maxlength="100" /></div>
	</div>
	<div class="group">
		<div class="label">园区坐标:</div>
		<div class="item">
			<input type="text" name="parkCoords" id="parkCoords" readonly="readonly" class="select_list" />
			<input type="hidden" id="lng" name="lng" />
			<input type="hidden" id="lat" name="lat" />
		</div>
	</div>
	<div class="group">
		<div class="label">联系人:</div>
		<div class="item"><input type="text" name="contactPerson" id="contactPerson" maxlength="10" /></div>
	</div>
	<div class="group">
		<div class="label">手机号码:</div>
		<div class="item"><input type="text" name="mobile" id="mobile" maxlength="20" /></div>
	</div>
	<div class="group">
		<div class="label">联系电话:</div>
		<div class="item"><input type="text" name="phone" id="phone" maxlength="20" /></div>
	</div>
	<div class="group">
		<div class="label">Email:</div>
		<div class="item"><input type="text" name="email" id="email" maxlength="50" /></div>
	</div>
	<div class="group">
		<div class="label">微信号:</div>
		<div class="item"><input type="text" name="wechat" id="wechat" maxlength="50" /></div>
	</div>
	<div class="group">
		<div class="label">园区图片:</div>
		<div class="item"><div id="logoUrl" class="myuploader myuploader-single"></div></div>
	</div>
	<div class="group">
		<div class="label">园区级别:</div>
		<div class="item"><input type="text" name="parkLevel" id="parkLevel" maxlength="8" value="1" /></div>
	</div>
	<div class="group">
		<div class="label">园区状态:</div>
		<div class="item">
			<input type="radio" id="parkStatus1" name="parkStatus" value="1" checked="checked" /><label for="parkStatus1" class="label">正常</label>
			<input type="radio" id="parkStatus2" name="parkStatus" value="2" /><label for="parkStatus2" class="label">停用</label>
		</div>
	</div>
	<div class="group">
		<div class="label">备注:</div>
		<div class="item"><textarea id="remark" name="remark"></textarea></div>
	</div>
	<div class="buttons">
		<button class="highlight" id="submit1" type="button">确定</button>
		<button type="button" id="cancel1">取消</button>
		<c:if test="${not empty groupid }">
		<input type="hidden" id="groupid" name="groupid" value="${groupid}" />
		</c:if>
	</div>
</div>
</form>
<%@ include file="/WEB-INF/sys/include/script.jsp" %>
<script src="${path}/res/js/webuploader/webuploader.min.js" type="text/javascript"></script>
<script src="${path}/res/js/webuploader/myUploader.js" type="text/javascript"></script>
<script type="text/javascript">
var myuploader;
$(function() {
	if($("#groupDisplay").length){
		createSelect("groupDisplay", "groupid", {
			tree:{url:'${path}/group/grouptree.json'},
			onSelected: function(id, name, data){
				$("#groupname").val(!data ? "" : name);
			}
		});
	}
	createSelect("companyDisplay", "companyid", {
		url:'${path}/company/getCompanyData.json?groupid=${groupid}'
	});
	myuploader = $("#logoUrl").myImgUploader({
		uploadDir: "farm_img"
	});
	$("#form").ligerForm({inputWidth: 300});
	
	verifyForm("form", {}, function(){
		$("#form").ajaxForm(function(data){
			UiUtil.isSuccess(data, "添加园区信息成功", function(){
				UiUtil.closeForm(true);
			});
		});
	});
	
	$("#submit1").click(function(){
		UiUtil.lockButton('submit1');
		if(!myuploader.isDone()){
			UiUtil.unlockButton('submit1');
			return
		}
		$("#form").submit();
	});

	$("#cancel1").click(function(){
		UiUtil.closeForm();
	});
	
	$("#parkCoords").click(function(){
		$.ligerDialog.open({
            top:20,
            width: 750,
            height: 530,
            title: "选择园区坐标 - 拖动标注点确定园区位置",
            url: "${path}/parkmap/setMapMarker.do?type=park&id=",
            data: {
            	lng: $("#lng").val(),
            	lat: $("#lat").val()
            },
            onClose:function(){
            	var dialogData = this.get('data');
            	if(dialogData.newLng){
            		$("#lng").val(dialogData.newLng);
            		$("#lat").val(dialogData.newLat);
            		setParkCoords();
            	}
            }
        });
	});
	
});
function setParkCoords(){
	var lng = $("#lng").val();
	if(lng){
		$("#parkCoords").val("经度："+lng+"；纬度："+$("#lat").val());
	}else{
		$("#parkCoords").val('');
	}
}
</script>
</body>
</html>